/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

#include "mqt_t__property_type.h"
#include <string.h>

// Code generated by code-generation. DO NOT EDIT.


// Create an empty NULL-struct
static const plc4c_mqtt_read_write_mqt_t__property_type plc4c_mqtt_read_write_mqt_t__property_type_null_const;

plc4c_mqtt_read_write_mqt_t__property_type plc4c_mqtt_read_write_mqt_t__property_type_null() {
  return plc4c_mqtt_read_write_mqt_t__property_type_null_const;
}

// Parse function.
plc4c_return_code plc4c_mqtt_read_write_mqt_t__property_type_parse(plc4c_spi_read_buffer* readBuffer, plc4c_mqtt_read_write_mqt_t__property_type** _message) {
    plc4c_return_code _res = OK;

    // Allocate enough memory to contain this data structure.
    (*_message) = malloc(sizeof(plc4c_mqtt_read_write_mqt_t__property_type));
    if(*_message == NULL) {
        return NO_MEMORY;
    }

    _res = plc4c_spi_read_unsigned_byte(readBuffer, 8, (uint8_t*) *_message);

    return _res;
}

plc4c_return_code plc4c_mqtt_read_write_mqt_t__property_type_serialize(plc4c_spi_write_buffer* writeBuffer, plc4c_mqtt_read_write_mqt_t__property_type* _message) {
    plc4c_return_code _res = OK;

    _res = plc4c_spi_write_unsigned_byte(writeBuffer, 8, *_message);

    return _res;
}

plc4c_mqtt_read_write_mqt_t__property_type plc4c_mqtt_read_write_mqt_t__property_type_value_of(char* value_string) {
    if(strcmp(value_string, "PAYLOAD_FORMAT_INDICATOR") == 0) {
        return plc4c_mqtt_read_write_mqt_t__property_type_PAYLOAD_FORMAT_INDICATOR;
    }
    if(strcmp(value_string, "MESSAGE_EXPIRY_INTERVAL") == 0) {
        return plc4c_mqtt_read_write_mqt_t__property_type_MESSAGE_EXPIRY_INTERVAL;
    }
    if(strcmp(value_string, "CONTENT_TYPE") == 0) {
        return plc4c_mqtt_read_write_mqt_t__property_type_CONTENT_TYPE;
    }
    if(strcmp(value_string, "RESPONSE_TOPIC") == 0) {
        return plc4c_mqtt_read_write_mqt_t__property_type_RESPONSE_TOPIC;
    }
    if(strcmp(value_string, "CORRELATION_DATA") == 0) {
        return plc4c_mqtt_read_write_mqt_t__property_type_CORRELATION_DATA;
    }
    if(strcmp(value_string, "SUBSCRIPTION_IDENTIFIER") == 0) {
        return plc4c_mqtt_read_write_mqt_t__property_type_SUBSCRIPTION_IDENTIFIER;
    }
    if(strcmp(value_string, "SESSION_EXPIRY_INTERVAL") == 0) {
        return plc4c_mqtt_read_write_mqt_t__property_type_SESSION_EXPIRY_INTERVAL;
    }
    if(strcmp(value_string, "ASSIGNED_CLIENT_IDENTIFIER") == 0) {
        return plc4c_mqtt_read_write_mqt_t__property_type_ASSIGNED_CLIENT_IDENTIFIER;
    }
    if(strcmp(value_string, "SERVER_KEEP_ALIVE") == 0) {
        return plc4c_mqtt_read_write_mqt_t__property_type_SERVER_KEEP_ALIVE;
    }
    if(strcmp(value_string, "AUTHENTICATION_METHOD") == 0) {
        return plc4c_mqtt_read_write_mqt_t__property_type_AUTHENTICATION_METHOD;
    }
    if(strcmp(value_string, "AUTHENTICATION_DATA") == 0) {
        return plc4c_mqtt_read_write_mqt_t__property_type_AUTHENTICATION_DATA;
    }
    if(strcmp(value_string, "REQUEST_PROBLEM_INFORMATION") == 0) {
        return plc4c_mqtt_read_write_mqt_t__property_type_REQUEST_PROBLEM_INFORMATION;
    }
    if(strcmp(value_string, "WILL_DELAY_INTERVAL") == 0) {
        return plc4c_mqtt_read_write_mqt_t__property_type_WILL_DELAY_INTERVAL;
    }
    if(strcmp(value_string, "REQUEST_RESPONSE_INFORMATION") == 0) {
        return plc4c_mqtt_read_write_mqt_t__property_type_REQUEST_RESPONSE_INFORMATION;
    }
    if(strcmp(value_string, "RESPONSE_INFORMATION") == 0) {
        return plc4c_mqtt_read_write_mqt_t__property_type_RESPONSE_INFORMATION;
    }
    if(strcmp(value_string, "SERVER_REFERENCE") == 0) {
        return plc4c_mqtt_read_write_mqt_t__property_type_SERVER_REFERENCE;
    }
    if(strcmp(value_string, "REASON_STRING") == 0) {
        return plc4c_mqtt_read_write_mqt_t__property_type_REASON_STRING;
    }
    if(strcmp(value_string, "RECEIVE_MAXIMUM") == 0) {
        return plc4c_mqtt_read_write_mqt_t__property_type_RECEIVE_MAXIMUM;
    }
    if(strcmp(value_string, "TOPIC_ALIAS_MAXIMUM") == 0) {
        return plc4c_mqtt_read_write_mqt_t__property_type_TOPIC_ALIAS_MAXIMUM;
    }
    if(strcmp(value_string, "TOPIC_ALIAS") == 0) {
        return plc4c_mqtt_read_write_mqt_t__property_type_TOPIC_ALIAS;
    }
    if(strcmp(value_string, "MAXIMUM_QOS") == 0) {
        return plc4c_mqtt_read_write_mqt_t__property_type_MAXIMUM_QOS;
    }
    if(strcmp(value_string, "RETAIN_AVAILABLE") == 0) {
        return plc4c_mqtt_read_write_mqt_t__property_type_RETAIN_AVAILABLE;
    }
    if(strcmp(value_string, "USER_PROPERTY") == 0) {
        return plc4c_mqtt_read_write_mqt_t__property_type_USER_PROPERTY;
    }
    if(strcmp(value_string, "MAXIMUM_PACKET_SIZE") == 0) {
        return plc4c_mqtt_read_write_mqt_t__property_type_MAXIMUM_PACKET_SIZE;
    }
    if(strcmp(value_string, "WILDCARD_SUBSCRIPTION_AVAILABLE") == 0) {
        return plc4c_mqtt_read_write_mqt_t__property_type_WILDCARD_SUBSCRIPTION_AVAILABLE;
    }
    if(strcmp(value_string, "SUBSCRIPTION_IDENTIFIER_AVAILABLE") == 0) {
        return plc4c_mqtt_read_write_mqt_t__property_type_SUBSCRIPTION_IDENTIFIER_AVAILABLE;
    }
    if(strcmp(value_string, "SHARED_SUBSCRIPTION_AVAILABLE") == 0) {
        return plc4c_mqtt_read_write_mqt_t__property_type_SHARED_SUBSCRIPTION_AVAILABLE;
    }
    return -1;
}

int plc4c_mqtt_read_write_mqt_t__property_type_num_values() {
  return 27;
}

plc4c_mqtt_read_write_mqt_t__property_type plc4c_mqtt_read_write_mqt_t__property_type_value_for_index(int index) {
    switch(index) {
      case 0: {
        return plc4c_mqtt_read_write_mqt_t__property_type_PAYLOAD_FORMAT_INDICATOR;
      }
      case 1: {
        return plc4c_mqtt_read_write_mqt_t__property_type_MESSAGE_EXPIRY_INTERVAL;
      }
      case 2: {
        return plc4c_mqtt_read_write_mqt_t__property_type_CONTENT_TYPE;
      }
      case 3: {
        return plc4c_mqtt_read_write_mqt_t__property_type_RESPONSE_TOPIC;
      }
      case 4: {
        return plc4c_mqtt_read_write_mqt_t__property_type_CORRELATION_DATA;
      }
      case 5: {
        return plc4c_mqtt_read_write_mqt_t__property_type_SUBSCRIPTION_IDENTIFIER;
      }
      case 6: {
        return plc4c_mqtt_read_write_mqt_t__property_type_SESSION_EXPIRY_INTERVAL;
      }
      case 7: {
        return plc4c_mqtt_read_write_mqt_t__property_type_ASSIGNED_CLIENT_IDENTIFIER;
      }
      case 8: {
        return plc4c_mqtt_read_write_mqt_t__property_type_SERVER_KEEP_ALIVE;
      }
      case 9: {
        return plc4c_mqtt_read_write_mqt_t__property_type_AUTHENTICATION_METHOD;
      }
      case 10: {
        return plc4c_mqtt_read_write_mqt_t__property_type_AUTHENTICATION_DATA;
      }
      case 11: {
        return plc4c_mqtt_read_write_mqt_t__property_type_REQUEST_PROBLEM_INFORMATION;
      }
      case 12: {
        return plc4c_mqtt_read_write_mqt_t__property_type_WILL_DELAY_INTERVAL;
      }
      case 13: {
        return plc4c_mqtt_read_write_mqt_t__property_type_REQUEST_RESPONSE_INFORMATION;
      }
      case 14: {
        return plc4c_mqtt_read_write_mqt_t__property_type_RESPONSE_INFORMATION;
      }
      case 15: {
        return plc4c_mqtt_read_write_mqt_t__property_type_SERVER_REFERENCE;
      }
      case 16: {
        return plc4c_mqtt_read_write_mqt_t__property_type_REASON_STRING;
      }
      case 17: {
        return plc4c_mqtt_read_write_mqt_t__property_type_RECEIVE_MAXIMUM;
      }
      case 18: {
        return plc4c_mqtt_read_write_mqt_t__property_type_TOPIC_ALIAS_MAXIMUM;
      }
      case 19: {
        return plc4c_mqtt_read_write_mqt_t__property_type_TOPIC_ALIAS;
      }
      case 20: {
        return plc4c_mqtt_read_write_mqt_t__property_type_MAXIMUM_QOS;
      }
      case 21: {
        return plc4c_mqtt_read_write_mqt_t__property_type_RETAIN_AVAILABLE;
      }
      case 22: {
        return plc4c_mqtt_read_write_mqt_t__property_type_USER_PROPERTY;
      }
      case 23: {
        return plc4c_mqtt_read_write_mqt_t__property_type_MAXIMUM_PACKET_SIZE;
      }
      case 24: {
        return plc4c_mqtt_read_write_mqt_t__property_type_WILDCARD_SUBSCRIPTION_AVAILABLE;
      }
      case 25: {
        return plc4c_mqtt_read_write_mqt_t__property_type_SUBSCRIPTION_IDENTIFIER_AVAILABLE;
      }
      case 26: {
        return plc4c_mqtt_read_write_mqt_t__property_type_SHARED_SUBSCRIPTION_AVAILABLE;
      }
      default: {
        return -1;
      }
    }
}

uint16_t plc4c_mqtt_read_write_mqt_t__property_type_length_in_bytes(plc4c_mqtt_read_write_mqt_t__property_type* _message) {
    return plc4c_mqtt_read_write_mqt_t__property_type_length_in_bits(_message) / 8;
}

uint16_t plc4c_mqtt_read_write_mqt_t__property_type_length_in_bits(plc4c_mqtt_read_write_mqt_t__property_type* _message) {
    return 8;
}
